package com.yw.master.rabbit.producer;

import javax.annotation.Resource;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import com.yw.master.rabbit.entity.RabbitMessage;

@Service
public class RmqProducer {
	
	 	@Resource(name="rabbitTemplate")  
	    private RabbitTemplate rabbitTemplate;  
	      
	    /** 
	     * 发送信息 
	     * @param msg 
	     */  
	    public void sendMessage(RabbitMessage  msg)  
	    {  
	        try {  
	            System.out.println(rabbitTemplate.getConnectionFactory().getHost());  
	            System.out.println(rabbitTemplate.getConnectionFactory().getPort());  
	            //发送信息  
	            rabbitTemplate.convertAndSend(msg.getExchange(), msg.getRouteKey(), msg);  
	        } catch (Exception e) {
	        	
	        }  
	    }
	 	
//	 	public void sendDataToCrQueue(Object obj) {
//	 		rabbitTemplate.convertAndSend("queue_one_key", obj);
//		}	
}
